//
//  VCOfLive.m
//  ProjectA_ManualGuest
//
//  Created by dingcong on 16/6/27.
//  Copyright © 2016年 丁聪. All rights reserved.
//

#import "VCOfLive.h"
#import "LiveCell.h"
#import "NetWorkingHandle.h"
#import "ModelOfLive.h"
@interface VCOfLive ()

@property(nonatomic, retain)NSMutableArray *mArrOfData;

@end

@implementation VCOfLive


- (void)dealloc{
    
    [_mArrOfData release];
    
    [super dealloc];
    
    
    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    [self GetData];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.tableView registerClass:[LiveCell class] forCellReuseIdentifier:@"live"];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 100;
    
}


- (void)GetData{
    
    NSString *url = @"http://m.shougongke.com/index.php?c=Index&a=salonList&vid=18";
    NetWorkingHandle *net = [[NetWorkingHandle alloc]init];
    
    [net netWorkingHandlerGetWithURL:url completion:^(id result, NSData *data, NSURLResponse *response, NSError *error) {
       
        NSArray *arr = [result objectForKey:@"data"];
        self.mArrOfData = [NSMutableArray array];
        for (NSDictionary *dic in arr)
        {
            ModelOfLive *model = [[ModelOfLive alloc]init];
            
            [model setValuesForKeysWithDictionary:dic];
            
            [self.mArrOfData addObject:model];
        }
        
        [self.tableView reloadData];
        
    }];
    
    
    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    NSLog(@"%ld", self.mArrOfData.count);
    return self.mArrOfData.count;
    
    
    
    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    LiveCell *cell = [tableView dequeueReusableCellWithIdentifier:@"live"];
    
    
    cell.model = self.mArrOfData[indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
    
    
    
    
    
}







@end
